// components/dialog-pay-desc/dialog-pay-desc.js
const payTypeMap = {
  '1': { label: '余额', icon: '/static/images/store/balance.png' },
  '2': { label: '微信支付', icon: '/static/images/store/wechat-pay-fill.png' },
  '3': { label: '支付宝', icon: '/static/images/store/alipay-fill.png' },
}
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    
  },

  /**
   * 组件的初始数据
   */
  data: {
    showPayDesc: false,
    showOpenDescType: '1', // 1押金详情 2会员详情
    openDescChecked: false, // 是否同意协议
    
    payTypeObj: payTypeMap['2'],
  },
  ready() {
    this.payTypeDialog = this.selectComponent('#dialog-paytype')
    this.costDetailDialog = this.selectComponent('#dialog-cost-detail')
  },
  /**
   * 组件的方法列表
   */
  methods: {
    handleConfirm() {
      this.triggerEvent('confirm')
      this.setData({ showPayDesc: false })
    },
    show(props = {}) {
      this.setData({ showPayDesc: true, ...props })
    },
    close() {
      this.setData({ showPayDesc: false })
    },
    // 支付方式点击事件
    handlePayTypeClick() {
      this.payTypeDialog.show()
    },
    // 同意协议
    handleOpenDescCheckedChange(event) {
      this.setData({ openDescChecked: event.detail,  })
    },
    handlePayTypeChange(event) {
      const payType = event.detail
      this.setData({ payTypeObj: payTypeMap[payType] })
    },
    // 打开明细
    handleCostDetailClick() {
      this.costDetailDialog.show({ showOpenDescType: this.data.showOpenDescType })
    },
  }
})